package com.ccx.mytemplate.util;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import jakarta.servlet.http.HttpServletResponse;

public class HttpUtil {

    public static void setWordResponseHeaders(HttpServletResponse response, String filename) {
        response.reset();
        response.setContentType("application/docx");
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, StandardCharsets.UTF_8));
    }

    public static void setExcelResponseHeaders(HttpServletResponse response, String filename) {
        response.reset();
        response.setContentType("application/xlsx");
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, StandardCharsets.UTF_8));
    }
}
